<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>


	<meta content="width=device-width, initial-scale=1.0" name="viewport" />

	<meta content="" name="description" />

	<meta content="" name="author" />

	<!-- BEGIN GLOBAL MANDATORY STYLES -->

	<link href="media/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>

	<link href="media/css/bootstrap-responsive.min.css" rel="stylesheet" type="text/css"/>

	<link href="media/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>

	<link href="media/css/style-metro.css" rel="stylesheet" type="text/css"/>

	<link href="media/css/style.css" rel="stylesheet" type="text/css"/>

	<link href="media/css/style-responsive.css" rel="stylesheet" type="text/css"/>

	<link href="media/css/default.css" rel="stylesheet" type="text/css" id="style_color"/>

	<link href="media/css/uniform.default.css" rel="stylesheet" type="text/css"/>

	<!-- END GLOBAL MANDATORY STYLES -->

	<!-- BEGIN PAGE LEVEL STYLES --> 

	<link href="media/css/jquery.gritter.css" rel="stylesheet" type="text/css"/>

	<link href="media/css/daterangepicker.css" rel="stylesheet" type="text/css" />

	<link href="media/css/fullcalendar.css" rel="stylesheet" type="text/css"/>

	<link href="media/css/jqvmap.css" rel="stylesheet" type="text/css" media="screen"/>

	<link href="media/css/jquery.easy-pie-chart.css" rel="stylesheet" type="text/css" media="screen"/>

	<!-- END PAGE LEVEL STYLES -->

	<link rel="shortcut icon" href="media/image/favicon.ico" />
	
	
	
		
<link rel="stylesheet" href="../layui/css/layui.css"  media="all">	
<script type="text/javascript" src="../axios/vue.js"></script>
<script type="text/javascript" src="../axios/axios.min.js"></script>
<script type="text/javascript" src="../axios/qs.js"></script>
<script type="text/javascript" src="../axios/getUrlParams.js"></script>
<script type="text/javascript" src="../layer/jquery-2.0.3.min.js"></script>
<script type="text/javascript" src="../layer/layer.js"></script>
	
</head>
<body>
<div class="page-content">

			<!-- BEGIN SAMPLE PORTLET CONFIGURATION MODAL FORM-->

			<div id="portlet-config" class="modal hide">

				<div class="modal-header">

					<button data-dismiss="modal" class="close" type="button"></button>

					<h3>portlet Settings</h3>

				</div>

				<div class="modal-body">


				</div>

			</div>

			<!-- END SAMPLE PORTLET CONFIGURATION MODAL FORM-->

			<!-- BEGIN PAGE CONTAINER-->

			<div class="container-fluid">

				<!-- BEGIN PAGE HEADER-->   

				<div class="row-fluid">

					<div class="span12">

						<!-- BEGIN STYLE CUSTOMIZER -->

						

						<!-- END BEGIN STYLE CUSTOMIZER -->     

						<h3 class="page-title">


						</h3>

						<ul class="breadcrumb">

							<li>

								<i class="icon-home"></i>

								<a href="index.html">首页</a> 

								<span class="icon-angle-right"></span>

							</li>

							<li>

								<a href="#">个人信息</a>

							</li>


						</ul>

					</div>

				</div>

				<!-- END PAGE HEADER-->

				<!-- BEGIN PAGE CONTENT-->



				<div class="row-fluid" id="app">

					<div class="span12">

						<!-- BEGIN VALIDATION STATES-->

						<div class="portlet box green">

							<div class="portlet-title">

								<div class="caption"><i class="icon-reorder"></i>个人信息</div>


							</div>

							<div class="portlet-body form">

								<!-- BEGIN FORM-->


								<form action="#" id="form_sample_2" class="form-horizontal">

									<div class="alert alert-error hide">

										<button class="close" data-dismiss="alert"></button>

										You have some form errors. Please check below.

									</div>
									
									<div class="control-group">

										<label class="control-label"><span class="required"></span></label>

										<div class="controls">

										     <div class="layui-upload">
						                          <div class="layui-upload-list">
						                              <input type="hidden" name="filename" id="filename" value="noimg.jpg"/>
						                              <img class="layui-upload-img" id="imgname" style="width: 10%">
						                              <p id="demoText"></p>
						                          </div>
						                          <button type="button" class="layui-btn" id="test1"><i class="layui-icon"></i>上传图片</button>
						                      </div>
										</div>

									</div>

                                    <div class="control-group">

                                        <label class="control-label">余额<span class="required">*</span></label>

                                        <div class="controls">

                                            <input type="text" v-model="total"  readonly="readonly" data-required="1" class="span6 m-wrap"/>

                                        </div>

                                    </div>


									<div class="control-group">

										<label class="control-label">用户名<span class="required">*</span></label>

										<div class="controls">

											<input type="text" v-model="username"  readonly="readonly" data-required="1" class="span6 m-wrap"/>

										</div>

									</div>

									<div class="control-group">

										<label class="control-label">密码<span class="required">*</span></label>

										<div class="controls">

											<input v-model="userpwd"  type="password" class="span6 m-wrap"/>

										</div>

									</div>

									<div class="control-group">

										<label class="control-label">姓名<span class="required">*</span></label>

										<div class="controls">

											<input v-model="realname" type="text" class="span6 m-wrap"/>

										</div>

									</div>

									<div class="control-group">

										<label class="control-label">性别<span class="required">*</span></label>

										<div class="controls">
											<select v-model="sex" class="span6 m-wrap" >


												<option value="男">男 </option>

												<option value="女">女 </option>

											</select>

										</div>

									</div>

									<div class="control-group">

										<label class="control-label">电话<span class="required">*</span></label>

										<div class="controls">

											<input v-model="tel" type="text" class="span6 m-wrap"/>

										</div>

									</div>
									
									<div class="control-group">

										<label class="control-label">身份证<span class="required">*</span></label>

										<div class="controls">

											<input v-model="idcard" type="text" class="span6 m-wrap"/>

										</div>

									</div>

									<div class="form-actions">

										<a type="submit" @click="edit()" class="btn green">保存</a>

										<a type="button" @click="clean()"  class="btn">清除</a>

									</div>

								</form>

								<!-- END FORM-->

							</div>

						</div>

						<!-- END VALIDATION STATES-->

					</div>

				</div>

				<!-- END PAGE CONTENT-->         

			</div>

			<!-- END PAGE CONTAINER-->

		</div>
</body>
<script src="../layui/layui.js" charset="utf-8"></script>
<script type="text/javascript">
	var qs = Qs
    var vmm = new Vue({
        el: '#app',
        data: {
        	username:"",
        	userpwd:"",
        	realname:"",
        	filename:"",
        	sex:"",
        	tel:"",
        	idcard:"",
            total:"",
        	id:"",
        	user:"",
        },
        mounted(){
        	this.show()
        	layui.use('upload', function(){
        	    var $ = layui.jquery
        	        ,upload = layui.upload;

        	    //普通图片上传
        	    var uploadInst = upload.render({
        	        elem: '#test1'
        	        ,url: 'uploadImg' //改成您自己的上传接口
        	        ,done: function(res){
        	            //如果上传失败
        	            console.log(res)
        	            $("#filename").val(res.data.src)
        	            $('#imgname').attr('src', "../upload/"+res.data.src); //图片链接（base64）
        	            if(res.code > 0){
        	                return layer.msg('上传失败');
        	            }
        	            //上传成功
        	        }
        	    });
        	});
        },
        methods: {
        	show(){
        		axios.post('checkadmin',qs.stringify({
                })).then(response =>{
                	if(response.data.data==200){
                		this.user = response.data.admin
                		this.username = this.user.username
                		this.userpwd = this.user.userpwd
                		this.realname = this.user.realname
                		this.sex = this.user.sex
                		this.tel = this.user.tel
                		this.id = this.user.id
                        this.total = this.user.total
                		this.idcard = this.user.idcard
                		$("#filename").val(this.user.filename)
                		$('#imgname').attr('src', "../upload/"+this.user.filename); //图片链接（base64）
                	}else{
                		location.replace("login.html")
                	}
                }).catch(error =>{
                    console.log(error)
                })
        	},
            edit() {
            	this.filename = $("#filename").val()
            	if(this.userpwd==""){
            		layer.msg("密码不能为空",{icon:5})
            		return false;
            	}
            	if(this.realname==""){
            		layer.msg("姓名不能为空",{icon:5})
            		return false;
            	}
            	if(this.tel==""){
            		layer.msg("电话不能为空",{icon:5})
            		return false;
            	}
            	if(this.idcard==""){
            		layer.msg("身份证不能为空",{icon:5})
            		return false;
            	}
                axios.post('userEdit',qs.stringify({
                	username:this.username,
                	userpwd:this.userpwd,
                	realname:this.realname,
                	filename:this.filename,
                	sex:this.sex,
                	tel:this.tel,
                	idcard:this.idcard,
                	id:this.id,
                })).then(response =>{
                	layer.msg("操作成功",{icon:6})
                }).catch(error =>{
                    console.log(error)
                })
            },
            

            clean(){
            	this.userpwd=""
            	this.realname=""
            	this.filename=""
            	this.tel=""
            	this.idcard=""
            },
            
            
        }
    });
</script>

</html>